package com.ssy.lingxi.gateway.filter;

import com.ssy.lingxi.gateway.service.ITokenAndAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * 全局Token校验，接口权限认证类
 * @author 王日灿、万宁
 * @version 2.0.0
 * @date 2020-06-07
 */
@Order(-1)
@Component
public class TokenAndAuthGlobalFilter implements GlobalFilter {

    @Autowired
    private ITokenAndAuthService tokenAndAuthService;

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        //TODO 先注释真正使用的时候放开注释使用注入服务进行用户鉴权
        //tokenAndAuthService.authToken(exchange);
        return chain.filter(exchange);
    }

//    /**
//     * 用户鉴权
//     * @author wrc
//     * @date 2020/5/21
//     */
//    private void authToken(ServerWebExchange serverWebExchange) {
//
//    }
}
